package javaer.starter.core.generator;

import freemarker.template.TemplateException;
import javaer.starter.core.BuildContext;
import javaer.starter.core.handler.SingleModuleTemplateHandler;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.io.IOException;


/**
 * @author yangzhen
 * @date 2023/6/15 14:31
 * @since 1.0.0
 */
@Component
public class SingleGenerator implements IGenerator {

    @Resource
    private SingleModuleTemplateHandler singleModuleTemplateHandler;

    @Override
    public void generate(BuildContext buildContext) throws TemplateException, IOException {
        if (buildContext.isSingle()) {
            singleModuleTemplateHandler.handle(initModuleContext(buildContext, buildContext.getStarterModule()));
        }
    }
}
